#############################################################################################
#                                                                                           #
#                   Copyright 2010-2013 Ning, Inc.                                          #
#                   Copyright 2014 Groupon, Inc.                                            #
#                   Copyright 2014 The Billing Project, LLC                                 #
#                                                                                           #
#      The Billing Project licenses this file to you under the Apache License, version 2.0  #
#      (the "License"); you may not use this file except in compliance with the             #
#      License.  You may obtain a copy of the License at:                                   #
#                                                                                           #
#          http://www.apache.org/licenses/LICENSE-2.0                                       #
#                                                                                           #
#      Unless required by applicable law or agreed to in writing, software                  #
#      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT            #
#      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the            #
#      License for the specific language governing permissions and limitations              #
#      under the License.                                                                   #
#                                                                                           #
#############################################################################################


#
#                       DO NOT EDIT!!!
#    File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
#


module Killbill
  module Plugin
    module Api

      java_package 'org.killbill.billing.security.api'
      class SecurityApi

        include org.killbill.billing.security.api.SecurityApi

        def initialize(real_java_api)
          @real_java_api = real_java_api
        end


        java_signature 'Java::void login(Java::java.lang.Object, Java::java.lang.Object)'
        def login(principal, credentials)

          # conversion for principal [type = java.lang.Object]
          principal = principal.to_s unless principal.nil?

          # conversion for credentials [type = java.lang.Object]
          credentials = credentials.to_s unless credentials.nil?
          @real_java_api.login(principal, credentials)
        end

        java_signature 'Java::void logout()'
        def logout()
        @real_java_api.logout()
      end

      java_signature 'Java::boolean isSubjectAuthenticated()'
      def is_subject_authenticated()
      res = @real_java_api.is_subject_authenticated()
      # conversion for res [type = boolean]
      if res.nil?
        res = false
      else
        tmp_bool = (res.java_kind_of? java.lang.Boolean) ? res.boolean_value : res
        res = tmp_bool ? true : false
      end
      return res
    end

    java_signature 'Java::java.util.Set getCurrentUserPermissions(Java::org.killbill.billing.util.callcontext.TenantContext)'
    def get_current_user_permissions(context)

      # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
      context = context.to_java unless context.nil?
      res = @real_java_api.get_current_user_permissions(context)
      # conversion for res [type = java.util.Set]
      tmp = []
      (res || []).each do |m|
        # conversion for m [type = org.killbill.billing.security.Permission]
        m = m.to_s.to_sym unless m.nil?
        tmp << m
      end
      res = tmp
      return res
    end

    java_signature 'Java::void checkCurrentUserPermissions(Java::java.util.List, Java::org.killbill.billing.security.Logical, Java::org.killbill.billing.util.callcontext.TenantContext)'
    def check_current_user_permissions(permissions, logical, context)

      # conversion for permissions [type = java.util.List]
      tmp = java.util.ArrayList.new
      (permissions || []).each do |m|
        # conversion for m [type = org.killbill.billing.security.Permission]
        m = Java::org.killbill.billing.security.Permission.value_of( m.to_s ) unless m.nil?
        tmp.add(m)
      end
      permissions = tmp

      # conversion for logical [type = org.killbill.billing.security.Logical]
      logical = Java::org.killbill.billing.security.Logical.value_of( logical.to_s ) unless logical.nil?

      # conversion for context [type = org.killbill.billing.util.callcontext.TenantContext]
      context = context.to_java unless context.nil?
      @real_java_api.check_current_user_permissions(permissions, logical, context)
    end

    java_signature 'Java::void addUserRoles(Java::java.lang.String, Java::java.lang.String, Java::java.util.List, Java::org.killbill.billing.util.callcontext.CallContext)'
    def add_user_roles(username, clearPassword, roles, context)

      # conversion for username [type = java.lang.String]
      username = username.to_s unless username.nil?

      # conversion for clearPassword [type = java.lang.String]
      clearPassword = clearPassword.to_s unless clearPassword.nil?

      # conversion for roles [type = java.util.List]
      tmp = java.util.ArrayList.new
      (roles || []).each do |m|
        # conversion for m [type = java.lang.String]
        m = m.to_s unless m.nil?
        tmp.add(m)
      end
      roles = tmp

      # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
      context = context.to_java unless context.nil?
      @real_java_api.add_user_roles(username, clearPassword, roles, context)
    end

    java_signature 'Java::void updateUserPassword(Java::java.lang.String, Java::java.lang.String, Java::org.killbill.billing.util.callcontext.CallContext)'
    def update_user_password(username, clearPassword, context)

      # conversion for username [type = java.lang.String]
      username = username.to_s unless username.nil?

      # conversion for clearPassword [type = java.lang.String]
      clearPassword = clearPassword.to_s unless clearPassword.nil?

      # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
      context = context.to_java unless context.nil?
      @real_java_api.update_user_password(username, clearPassword, context)
    end

    java_signature 'Java::void updateUserRoles(Java::java.lang.String, Java::java.util.List, Java::org.killbill.billing.util.callcontext.CallContext)'
    def update_user_roles(username, roles, context)

      # conversion for username [type = java.lang.String]
      username = username.to_s unless username.nil?

      # conversion for roles [type = java.util.List]
      tmp = java.util.ArrayList.new
      (roles || []).each do |m|
        # conversion for m [type = java.lang.String]
        m = m.to_s unless m.nil?
        tmp.add(m)
      end
      roles = tmp

      # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
      context = context.to_java unless context.nil?
      @real_java_api.update_user_roles(username, roles, context)
    end

    java_signature 'Java::void invalidateUser(Java::java.lang.String, Java::org.killbill.billing.util.callcontext.CallContext)'
    def invalidate_user(username, context)

      # conversion for username [type = java.lang.String]
      username = username.to_s unless username.nil?

      # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
      context = context.to_java unless context.nil?
      @real_java_api.invalidate_user(username, context)
    end

    java_signature 'Java::java.util.List getUserRoles(Java::java.lang.String, Java::org.killbill.billing.util.callcontext.TenantContext)'
    def get_user_roles(username, tenantContext)

      # conversion for username [type = java.lang.String]
      username = username.to_s unless username.nil?

      # conversion for tenantContext [type = org.killbill.billing.util.callcontext.TenantContext]
      tenantContext = tenantContext.to_java unless tenantContext.nil?
      res = @real_java_api.get_user_roles(username, tenantContext)
      # conversion for res [type = java.util.List]
      tmp = []
      (res || []).each do |m|
        # conversion for m [type = java.lang.String]
        tmp << m
      end
      res = tmp
      return res
    end

    java_signature 'Java::void addRoleDefinition(Java::java.lang.String, Java::java.util.List, Java::org.killbill.billing.util.callcontext.CallContext)'
    def add_role_definition(role, permissions, context)

      # conversion for role [type = java.lang.String]
      role = role.to_s unless role.nil?

      # conversion for permissions [type = java.util.List]
      tmp = java.util.ArrayList.new
      (permissions || []).each do |m|
        # conversion for m [type = java.lang.String]
        m = m.to_s unless m.nil?
        tmp.add(m)
      end
      permissions = tmp

      # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
      context = context.to_java unless context.nil?
      @real_java_api.add_role_definition(role, permissions, context)
    end

    java_signature 'Java::java.util.List getRoleDefinition(Java::java.lang.String, Java::org.killbill.billing.util.callcontext.TenantContext)'
    def get_role_definition(role, tenantContext)

      # conversion for role [type = java.lang.String]
      role = role.to_s unless role.nil?

      # conversion for tenantContext [type = org.killbill.billing.util.callcontext.TenantContext]
      tenantContext = tenantContext.to_java unless tenantContext.nil?
      res = @real_java_api.get_role_definition(role, tenantContext)
      # conversion for res [type = java.util.List]
      tmp = []
      (res || []).each do |m|
        # conversion for m [type = java.lang.String]
        tmp << m
      end
      res = tmp
      return res
    end
  end
end
end
end
